< previous page page_835 next page >

Page 835
        strLine = strLine & vbQuote & varParms(lngLoop) & vbQuote & ","
    Next
    strLine = Left(strLine, Len(strLine) - 1) ' drop last comma
    '
    ' send it out
    Print #intFileHandle, strLine
    '
    Exit Sub
    '
LocalErr:
    Err.Raise Err.Number, App.EXEName & ".logObject", Err.Description
    '
End Sub
Tip.gif
Notice that you are enclosing all items in quotation marks. This makes it easier for you to convert this file into a database in the future (if you want to) because most conversion tools expect strings in quotations.

Notice that there is only one parameter sent to the WriteLog method. This parameter is actually an array of parameters. By using the ParamArray keyword, you are telling Visual Basic to put all parameters sent to this method into a single variant array. Now, whether the caller sends you 1 or 100 items in the call, you can access them all through this array.
Now you can add the two Private support routines OpenLogFile and WriteHeader. These are called as needed from the WriteLog method (see Listing 21.38).
Type.gifListing 21.38. Coding the OpenLogFile method.
Private Sub OpenLogFile()
    '
    ' open the file for output
    '
    On Error Resume Next
    '
    ' see if the file exists
    intFileHandle = FreeFile
    Open strFileName For Input As intFileHandle
    '
    ' if missing, make a new one
    If Err.Number <> 0 Then
        Open strFileName For Output As intFileHandle
        WriteHeader
    End If
    Close #intFileHandle
    '
continues

 
< previous page page_835 next page >

If you like this book, buy it!